package panel.viewSpots
{
	import assists.SizeManager;
	import assists.resource.ResourceLoader;
	
	import com.greensock.TweenLite;
	
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.MouseEvent;
	
	import panel.viewSpots.navigation.BtnClouree;
	
	public class MenuDownSlide extends Sprite
	{
		private var _stage:Stage;
		private var _loader:ResourceLoader;
		
		private var _dataList:Array = [];
		private var _isMove:Boolean;
		public function MenuDownSlide(stage:Stage,loader:ResourceLoader)
		{
			_stage = stage;
			_loader = loader;
			init();
		}
		
		private function init():void
		{
			
		}
		
		public function show(list:Array):void
		{
			if(_isMove) return;
			_dataList = list;
			for(var i:int=0;i<_dataList.length;i++)
			{
				var btn:BtnClouree = new BtnClouree();
				btn.label(_dataList[i].desc);
				btn.onCallBack = _dataList[i].func;
				btn.width = _stage.stageWidth * 0.8;
				btn.height = _stage.stageHeight * 0.1;
				btn.x = (_stage.stageWidth - btn.width) * 0.5;
				btn.y = i * btn.height * 1.2 + SizeManager.heightDistance;
				this.addChild(btn);
			}
			drawGround(btn.height);
		}
		
		public function start():void
		{
			TweenLite.to(this,1,{y:this.y - this.height,onComplete:onMoveEnd});
		}
		
		private function drawGround(itemHeight:int):void
		{
			this.graphics.clear();
			this.graphics.beginFill(0,0.7);
			this.graphics.drawRect(_stage.stageWidth * 0.05,0,_stage.stageWidth * 0.9,itemHeight * 1.2 * _dataList.length + SizeManager.heightDistance);
			this.graphics.endFill();
		}
		
		public function backMenu():void
		{
			if(_isMove) return;
			TweenLite.to(this,1,{y:this.y + this.height,onComplete:onMoveEnd});
		}
		
		public function get moveState():Boolean
		{
			return _isMove;
		}
		
		private function onMoveEnd():void
		{
			_isMove = false;
		}
		
	}
}